import java.util.Scanner;
public class Main2{
    public static void main(String[] args){
        Scanner scanner=new Scanner(System.in);
        int l=scanner.nextInt();
        int m=scanner.nextInt();
        int[] a;
        a=new int[l+1];
        for(int i=0;i<=l;i++){
            a[i]=1;
        }
        for(int i=1;i<=m;i++){
            int left=scanner.nextInt();
            int right=scanner.nextInt();
            for(int j=left;j<=right;j++){
                a[j]=0;
            }
        }
        int num=0;
        for(int i=0;i<=l;i++){
            if(a[i]==1)num++;
        }
        System.out.print(num);
    }
}